package statement

import (
	"gitee.com/kristas/booting-go/framework/common/util/reflectx"
	"gitee.com/kristas/booting-go/framework/core/bean"
	"reflect"
)

func Compile(state Statement) {
	reflectx.ForEachField(state, true, func(field reflect.StructField, value reflect.Value) error {
		if reflect.New(field.Type).Type().Implements(reflect.TypeOf(new(Statement)).Elem()) {
			state.SetTag(field.Tag)
		}
		return nil
	})
}

// Statement base statement
type Statement interface {
	//bean.Bean
	SetTag(tag reflect.StructTag)
	GetTag(key string) (string, bool)
}

// Service abstract service layer
type Service interface {
	bean.Bean
	ServiceFor() string
}

// AutoConfigure auto configure bean
type AutoConfigure interface {
	bean.Bean
	Prefix() string
}

// ApplicationRunner will be called when framework boot up
type ApplicationRunner interface {
	bean.Bean
	Order() int
	Run() error
}
